package cn.iocoder.yudao.module.xhyy.dal.mysql.carousel;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.xhyy.controller.admin.carousel.vo.CarouselPageReqVO;
import cn.iocoder.yudao.module.xhyy.controller.app.carousel.vo.AppCarouselPageReqVO;
import cn.iocoder.yudao.module.xhyy.dal.dataobject.carousel.CarouselDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 轮播图 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CarouselMapper extends BaseMapperX<CarouselDO> {

    default PageResult<CarouselDO> selectPage(CarouselPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CarouselDO>()
                .eqIfPresent(CarouselDO::getId, reqVO.getId())
                .eqIfPresent(CarouselDO::getTitle, reqVO.getTitle())
                .orderByDesc(CarouselDO::getId));
    }

    default PageResult<CarouselDO> selectPage(AppCarouselPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CarouselDO>()
                .eqIfPresent(CarouselDO::getTitle, reqVO.getTitle())
                .eqIfPresent(CarouselDO::getSort, reqVO.getSort())
                .eqIfPresent(CarouselDO::getImageUrl, reqVO.getImageUrl())
                .orderByDesc(CarouselDO::getSort));
    }

}